perf(scan): reuse loaded global index planning context - #267
Conversation
|
The failure came from process-wide BTree pages warmed by an earlier fixture. The cache key now includes the backend namespace, so cross-fixture pages cannot be reused. I restored the exact file-open assertion; all 12 primary-key sorted-index integration cases pass for Parquet and ORC. The latest fork workflows are waiting for maintainer approval. |
|
Thanks for working on the repeated Global Index lookup performance. Some downstream query engines, such as StarRocks, have a similar requirement. Their approach is to create a The process-wide design in this PR introduces additional concepts and hidden global state, including the shared Could we instead encourage the query engine to split the query into two explicit stages?
The engine can cache readers using a key containing the table identity, snapshot/index generation, field, index type, shard/partition, row range, and relevant options. It should also ensure that the index lookup and subsequent data scan use the same snapshot, and respect This keeps cache ownership, eviction, memory accounting, and isolation under the query engine's control while reusing the existing public API. Could we evaluate this approach before adding process-wide cache sharing to paimon-cpp? |
|
Agreed. I removed the process-wide reader and BTree cache registry, namespace, and allocator-lifetime changes. The query engine now owns cross-query This PR is now limited to reusing the schema, snapshot context, executor, memory pool, and caller-provided manifest cache already available inside one |
Purpose
Linked issue: N/A
DataEvolutionBatchScanusedGlobalIndexScan::Create()while planning an index predicate. That public entry point reloaded the latest table schema and snapshot and constructed its own planning context, even thoughTableScanhad already resolved the same state.The DataEvolution scan now builds its internal
GlobalIndexScanImplfrom the schema, snapshot manager,CoreOptions, filesystem, executor, memory pool, and caller-provided cache already owned by the currentTableScan. The index and data planning stages therefore use the same scan context, and repeated plans can hit the cache supplied throughScanContextBuilder::WithCache().This PR does not retain
GlobalIndexReaderobjects or BTree pages across queries and adds no process-global registry. Cross-query reader ownership, eviction, memory accounting, andIsThreadSafe()handling remain query-engine responsibilities through the existing publicGlobalIndexScan,CreateReader, andSetGlobalIndexResultAPIs.Tests
paimon-global-index-test: 132/132 passed.FileFormat/GlobalIndexTest.TestDataEvolutionBatchScan/*: 6/6 passed.git diff --checkpasses.The local environment does not have
pre-commitinstalled; GitHub Actions cover the repository lint hooks.API and Format
No public API, storage-format, or protocol change. The modified constructor is internal to the core implementation.
Documentation
No user-facing option or behavior change.
Generative AI tooling
Generated-by: Codex (GPT-5)